<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./lib/vue_2.5.22.js"></script>
<script src="./lib/vue-router_3.0.2.js"></script>
</head>
<body>

    <div id="app">
        <h1>vue-router的使用【和Django的url分发操作一样】</h1>
        <ol>
            <li>在导入vue包以后导入router包</li>
            <li>添加路由连接</li>
            <li>添加路由填充位置</li>
            <li>定义路由组件【相当于Django的view视图】</li>
            <li>配置路由规则并创建实例【相当于Django的 url分发到view】</li>
            <li>挂载路由【相当于Django中的子模块的url列表添加到根url中】</li>
        </ol>
        <!-- 第二步 添加路由连接 -->
        <router-link to="/user">User</router-link>
        <router-link to="/register">Register</router-link>

        <!-- 第三步添加路由填充位置 -->
        <router-view></router-view>
    </div>

<script>
    // 第四步创建路由对象
    const User = {
        template:'<h1>用户组件</h1>'
    }
    const Register = {
        template:'<h1>注册组件</h1>'
    }
    const router = new VueRouter({
        routes:[
            {path:'/user',component:User},
            {path:'/register',component:Register},
        ]
    })

    var vm = new Vue({
        el:'#app',
        data:{

        },
        router
    })
</script>
</body>

</html>